<?php

namespace falcon5\inc\Infrastructure\Providers;

use falcon5\inc\Helpers\AssetsHelper;
use Dotenv\Dotenv;
use hollisho\helpers\EnvHelper;
use lucatume\DI52\ServiceProvider;

/**
 * @author Hollis
 * @desc env文件
 * Class DotEnvServiceProvider
 * @package htranslate\inc\Infrastructure\ServiceProvider
 */
class DotEnvServiceProvider extends ServiceProvider
{

    public function register()
    {
        $this->container->singleton('env', static function () {
            /**
             * 加载env配置
             */
            $dotenv = Dotenv::create(
                EnvHelper::getRepository(),
                AssetsHelper::getRootPath()
            );

            $dotenv->safeLoad();
            return $dotenv;
        });
    }
}